﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Serialization;
using System.Xml.Serialization;

public partial class JSON_GetJson : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public String CreateIdentifier()
    {
        return System.Guid.NewGuid().ToString("N");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        JavaScriptSerializer jscvt = new JavaScriptSerializer();
       CsListItem listitem = new CsListItem();
        listitem.ListItemIdentifier = CreateIdentifier();
        listitem.ListItemName = @"天花板验收";
        listitem.ListItemContent = @"天花板是否漏水,发霉,变色,涂抹均匀等";
        listitem.ListItemRemark = @"注意大局和角落协调";

        CsListItem listitem2 = new CsListItem();
        listitem2.ListItemIdentifier = CreateIdentifier();
        listitem2.ListItemName = @"天花板验收";
        listitem2.ListItemContent = @"天花板是否漏水,发霉,变色,涂抹均匀等";
        listitem2.ListItemRemark = @"注意大局和角落协调";

        CsListItems lists = new CsListItems();
        lists.Item = new CsListItem[] { listitem, listitem2 };

        Response.Write(jscvt.Serialize(lists));
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        JavaScriptSerializer jscvt = new JavaScriptSerializer();
        CsListItem listitem = new CsListItem();
        listitem.ListItemIdentifier = CreateIdentifier();
        listitem.ListItemName = @"天花板验收";
        listitem.ListItemContent = @"天花板是否漏水,发霉,变色,涂抹均匀等";
        listitem.ListItemRemark = @"注意大局和角落协调";
        Response.Write(jscvt.Serialize(listitem));
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        JavaScriptSerializer jscvt = new JavaScriptSerializer();
        CsListItem model=jscvt.Deserialize<CsListItem>(TextBox1.Text);
    }

    protected void Button4_Click(object sender, EventArgs e)
    {
        JavaScriptSerializer jscvt = new JavaScriptSerializer();
        CsListItems model = jscvt.Deserialize<CsListItems>(TextBox1.Text);
    }
}


public class CsListItem
{
    [XmlElement(ElementName = "ListItemIdentifier", Type = typeof(string))]
    public String ListItemIdentifier;
    [XmlElement(ElementName = "ListItemName", Type = typeof(string))]
    public String ListItemName;
    [XmlElement(ElementName = "ListItemContent", Type = typeof(string))]
    public String ListItemContent;
    [XmlElement(ElementName = "ListItemRemark", Type = typeof(string))]
    public String ListItemRemark;
}


public class CsListItems
{
    [XmlElement(ElementName = "Item")]
    public CsListItem[] Item;
}


